<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    
  </style>
</head>
<body>
  
</body>
<script>

  var num = 266;
  console.log( num.toString( 2 ) );
  console.log( num.toString( 8 ) );
  console.log( num.toString() );
  console.log( num.toString( 16 ) );

  var str = "11100101";
  console.log( parseInt(str, 2) );
  console.log( parseInt(str, 8) );
  console.log( parseInt(str) );
  console.log( parseInt(str, 16) );

  // 十六进制转八进制
  // 先转十进制
  var str2 = "1a2b3c";
  console.log( parseInt(str2, 16).toString(8) );

  // 十六进制和十进制的测试
  console.log( (20013).toString(16) );
  console.log( parseInt("4e2d", 16) );

  // 其他非 常用进制的测试
  var n = 365;
  console.log( n.toString(2) );
  console.log( n.toString(3) );
  console.log( n.toString(4) );
  console.log( n.toString(5) );
  console.log( n.toString(6) );
  console.log( n.toString(7) );
  console.log( n.toString(8) );
  console.log( n.toString(9) );
  
</script>
</html>